
#include "logger.h"
#include "logger_manager.h"

#include <boost/format.hpp>
#include <boost/thread.hpp>



Logger netLogger("Net",LogConfig::LOGGER_COUT|LogConfig::LOGGER_FILE);

#define NET_DEBUG(args) netLogger.debug() args
#define NET_STACK(fmt,args) do { boost::format fmter(fmt); netLogger.stack() << fmter % args ; } while (0)
//#define NET_DEBUG(args)


void foo()
{
    printf("enter foo ");
	netLogger.stack() <<"Enter foo \n";
	netLogger.debug()<< "==========================================\n" ;
    netLogger.debug("Log debug ##########%d \n",111);
    netLogger.flush();
}

int main(int argc, char * argv[])
{

    boost::shared_ptr<FileAppenderConfig> fileConfig(new FileAppenderConfig());
	LoggerManager::instance().add_file_appender(fileConfig);
	LoggerManager::instance().start_logger();

	netLogger.set_level(LogConfig::LV_ALL);

	netLogger.debug()<< "Debug log \n";
	NET_DEBUG(<<"debug data\n");

	NET_STACK("%d,%s",10%"abc");

	netLogger.info()<<"information ";
	netLogger.flush();

    //sleep(1);
    printf("sleep 1");
    boost::thread log_thread(foo);

	sleep(1000);
	return 0;
}
